package net.kmtarena.util;

import javax.servlet.http.HttpServletRequest;
/**
 * 获取IP地址
 * @author Funnyking
 * funnyking@139.com by 2012-11-27
 */
public class IP {
	/**
	 * 获取客户端IP
	 * 
	 * @return IP 客户端IP地址
	 */
	public static final String getIP(HttpServletRequest request) {
		 String ip = request.getHeader("x-forwarded-for");   
	       if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {   
	           ip = request.getHeader("Proxy-Client-IP");   
	       }   
	       if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {   
	           ip = request.getHeader("WL-Proxy-Client-IP");   
	       }   
	       if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {   
	           ip = request.getRemoteAddr();   
	       }   
	       return ip;
	}
}
